package br.com.geftu.util;

import javax.swing.JOptionPane;
import javax.swing.text.MaskFormatter;

public class MaskF{  
 private static MaskFormatter formato = null;  
 public static MaskFormatter mascara(String s) {   
 try {  
 if (s == "codigo"){  
 formato = new MaskFormatter("####");   
 }  
 else if (s == "mesano"){  
 formato = new MaskFormatter("######");   
 }
  else if (s == "data"){  
 formato = new MaskFormatter("##/##/####");   
 }
 else if (s == "cpf"){
     formato = new MaskFormatter("###.###.###-##");
 }
 formato.setPlaceholderCharacter(' ');  
 formato.setCommitsOnValidEdit(true);  
 } catch (java.text.ParseException exc) {  
     JOptionPane.showMessageDialog(null, "teste");
 System.err.println("formatter is bad: " + exc.getMessage());  
 System.exit(-1);

 }  
 return formato;  
 }  
}  